//
//  DishRelateDetailView.m
//  XRmenu
//
//  Created by gaomz on 11-3-30.
//  Copyright 2011 E0571. All rights reserved.
//

#import "DishRelateDetailView.h"


@implementation DishRelateDetailView


-(id)initWithViewName:(NSString *)vname product:(Product *)product
{
NSDictionary* aDic = [self findNode:APPSESSION.allconfig withKey:vname];
if ((self=[super initWithConfig:aDic])) {
        // Initialization code.
	
	UIButton *btnPhoto;
	UILabel  *lblDishName;
	UILabel  *lbldishPrice;
	
	
	btnPhoto = (UIButton *)[self viewWithTag:kTagOfStartBT];
	lblDishName=(UILabel *)[self viewWithTag:kTagOfStartLabel];
	lbldishPrice=(UILabel *)[self viewWithTag:kTagOfStartLabel+1];

	XRmenuError *error=nil;
	UIImage *photoImg = getAlbumImg(product.pEntityId,error);
	[btnPhoto setImage:photoImg forState:UIControlStateNormal];
	[btnPhoto setImage:photoImg forState:UIControlStateSelected];
	[btnPhoto setImage:photoImg forState:UIControlStateHighlighted];

	
	lbldishPrice.text=[NSString stringWithFormat:@"%@%d",[APPSESSION.allconfig getStringValueAtPath:@"System Config/currency"],[product.pSalePrice intValue]];	
	lblDishName.text=[XRmenuPublic jsonfield:product.pName];
	
	pEntityId = [[NSString alloc] initWithString:product.pProductId];
	rProduct= [product retain];
    }
    return self;
}

-(void) buttonClicked:(id)sender
{
	//[[NSNotificationCenter defaultCenter] postNotificationName:kMessage_Dish_AlbumToPhoto object:pEntityId userInfo:nil];
	[[NSNotificationCenter defaultCenter] postNotificationName:kMessage_Dish_changeRelateDish object:rProduct userInfo:nil];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code.
}
*/

- (void)dealloc {
	[rProduct release];
	[pEntityId release];
    [super dealloc];
}


@end
